-module(emqx_plugin_kafka_schema).

-include_lib("hocon/include/hoconsc.hrl").
-include_lib("typerefl/include/types.hrl").

-behaviour(hocon_schema).

-export([namespace/0, roots/0, fields/1, desc/1]).

namespace() -> plugin_kafka.

roots() ->
    [plugin_kafka].

fields(plugin_kafka) ->
    [
       {
            config_path,
            ?HOCON(
                string(),
                #{
                required => false,
                desc => ?DESC(config_path)
                }
            )
        },
        {
            bootstrap_hosts,
            ?HOCON(
                list(string()),
                #{
                required => true,
                desc => "kafka bootstrap hosts [\"host1:port1\", \"host2:port2\"]"
                }
            )    
        },
        {
            reconnect_cool_down_seconds,
            ?HOCON(
                integer(),
                #{
                required => false,
                default => 10,
                desc => "reconnect cool down seconds"
                }
            )
        },
        {
            query_api_versions,
            ?HOCON(
                boolean(),
                #{
                required => false,
                default => true,
                desc => "query api versions"
                }
            )
        },
        {
            topic,
            ?HOCON(
                string(),
                #{
                required => true,
                default => "test",
                desc => "kafka topic name"
                }
            )
        },
        {
            mqtt_topics,
            ?HOCON(
                list(string()),
                #{
                required => true,
                default => ["test/#"],
                desc => "mqtt topic name list like [\"test1/#\", \"test2/#\"]"
                }
            )
        }
    ].

desc(plugin_kafka) -> "kafka plugin configuration.";
desc(_) -> undefined.
